let http = require('http').Server()
let io = require('socket.io')(http)
let Redis = require('ioredis')
let redis = new Redis({
  password: '000',
})
let socketPort = 6001

redis.subscribe(['lotto_show'])

redis.on('message', function (channel, message) {
  try {
    message = JSON.parse(message)
  } catch (e) {

  }
  console.log(channel + ':' + message.event, message.data)
  io.emit(channel + ':' + message.event, message.data)
})

http.listen(socketPort, function () {
  console.log('Server is running at ' + socketPort + '!')
})
